clear
set mem 400m

********************************************************************************
*** REGRESSIONS ***
********************************************************************************

*** from excel file: "TKdata_2023_11_27_complete.xlsx"
import excel "C:\Users\dallapellegrina\OneDrive - Università degli Studi di Milano-Bicocca\Desktop\USB_2023_07_28\CRIME_COURTS\CC\POLAND\JLEO\TKdata_2023_11_27_complete.xlsx", sheet("Foglio1") firstrow
save "C:\Users\dallapellegrina\OneDrive - Università degli Studi di Milano-Bicocca\Desktop\USB_2023_07_28\CRIME_COURTS\CC\POLAND\JLEO\TKdata_2023_11_27_complete.dta", replace

encode judges, generate(judges_c)
sort judges_c
encode political_affiliation, generate(political_affiliation_c)
tabulate political_affiliation, gen (political_affiliation)
rename political_affiliation1  political_affiliation_AWS
rename political_affiliation2  political_affiliation_LPR_SMBR
rename political_affiliation3  political_affiliation_PO
rename political_affiliation4  political_affiliation_PO_2
replace political_affiliation_PO=1 if political_affiliation_PO_2==1
drop political_affiliation_PO_2
rename political_affiliation5  political_affiliation_PSL
rename political_affiliation6  political_affiliation_PIS
rename political_affiliation7  political_affiliation_SLD
rename political_affiliation8  political_affiliation_UW

gen mandate_start=1995 if judges=="Jadwiga Skórzewska-Łosiak"
replace mandate_start=1997 if judges=="Teresa Dębowska-Romanowska"
replace mandate_start=1997  if judges=="Wiesław Johann"
replace mandate_start=1997  if judges=="Biruta Lewaszkiewicz-Petrykowska"
replace mandate_start=1997  if judges=="Andrzej Mączyński"
replace mandate_start=1997  if judges=="Marek Safjan"
replace mandate_start=1997  if judges=="Marian Zdyb"
replace mandate_start=1998  if judges=="Jerzy Ciemniewski"
replace mandate_start=1999  if judges=="Jerzy Stępień"
replace mandate_start=2001  if judges=="Marian Grzybowski"
replace mandate_start=2001  if judges=="Marek Mazurkiewicz"
replace mandate_start=2001  if judges=="Janusz Niemcewicz"
replace mandate_start=2001  if judges=="Mirosław Wyrzykowski"
replace mandate_start=2001  if judges=="Bohdan Zdziennicki"
replace mandate_start=2002  if judges=="Ewa Łętowska"
replace mandate_start=2003  if judges=="Adam Jamróz"
replace mandate_start=2006  if judges=="Zbigniew Cieślak"
replace mandate_start=2006  if judges=="Maria Gintowt-Jankowicz"
replace mandate_start=2006  if judges=="Wojciech Hermeliński"
replace mandate_start=2006  if judges=="Marek Kotlinowski"
replace mandate_start=2006  if judges=="Teresa Liszcz"
replace mandate_start=2007  if judges=="Mirosław Granat"
replace mandate_start=2007  if judges=="Andrzej Rzepliński"
replace mandate_start=2008  if judges=="Stanisław Biernat"
replace mandate_start=2010  if judges=="Stanisław Rymar"
replace mandate_start=2010  if judges=="Piotr Tuleja"
replace mandate_start=2010  if judges=="Sławomira Wronkowska-Jaśkiewicz"
replace mandate_start=2010  if judges=="Marek Zubik"
replace mandate_start=2011  if judges=="Małgorzata Pyziak-Szafnicka"
replace mandate_start=2011  if judges=="Andrzej Wróbel"
replace mandate_start=2012  if judges=="Leon Kieres"
replace mandate_start=2015  if judges=="Henryk Cioch"
replace mandate_start=2015  if judges=="Lech Morawski"
replace mandate_start=2015  if judges=="Mariusz Muszyński"
replace mandate_start=2015  if judges=="Julia Przyłębska"
replace mandate_start=2015  if judges=="Piotr Pszczółkowski"
replace mandate_start=2016  if judges=="Zbigniew Jędrzejewski"
replace mandate_start=2016  if judges=="Michał Warciński"
replace mandate_start=2017  if judges=="Grzegorz Jędrejek"
replace mandate_start=2017  if judges=="Justyn Piskorski"
replace mandate_start=2017  if judges=="Andrzej Zielonacki"
replace mandate_start=2018  if judges=="Jarosław Wyrembak"
replace mandate_start=2019  if judges=="Krystyna Pawłowicz"
replace mandate_start=2019  if judges=="Stanisław Piotrowicz"
replace mandate_start=2019  if judges=="Jakub Stelina"
replace mandate_start=2019  if judges=="Wojciech Sych"
replace mandate_start=2020  if judges=="Bartłomiej Sochański"
replace mandate_start=2020  if judges=="Rafał Wojciechowski"
replace mandate_start=2022  if judges=="Bogdan Święczkowski"
gen appointed_after2015=1 if mandate_start >=2016
recode appointed_after2015 .=0
sort date_out

*before Setember 2005:          SLD / PSL / UP  OK
*October 2005 - April 2006:    PiS
*May 2006 - October 2007:      PiS / LPR / Samoobrona
*November 2007 - October 2015: PO / PSL
*November 2015:                PiS
* DATE OUT

gen political_cycle_PO=1 if political_cycle=="PO" 
recode political_cycle_PO .=0
gen political_cycle_PIS=1 if political_cycle=="PiS"
recode political_cycle_PIS .=0
gen political_cycle_SLD=1 if political_cycle=="SLD" 
recode political_cycle_SLD .=0

gen political_alignment_PO=1 if political_cycle=="PO" & political_affiliation_PO==1
recode political_alignment_PO .=0
gen political_alignment_PIS=1 if political_cycle=="PiS" & political_affiliation_PIS==1
recode political_alignment_PIS .=0
gen political_alignment_SLD=1 if political_cycle=="SLD" & political_affiliation_SLD==1
recode political_alignment_SLD .=0

gen political_cycle_alt_NOPIS=1 if political_cycle!="PiS" 
recode political_cycle_alt_NOPIS .=0
gen political_cycle_alt_PIS=1   if political_cycle=="PiS"
recode political_cycle_alt_PIS .=0

gen political_alignment_alt_NOPIS=1 if political_cycle!="PiS" & political_affiliation_PIS!=1
recode political_alignment_alt_NOPIS .=0
gen political_alignment_alt_PIS=1   if political_cycle!="PiS" & political_affiliation_PIS==1
recode political_alignment_alt_PIS .=0

gen type_K=1 if type=="K"
recode type_K .=0

egen dec_conc=concat(year no_year decision_no type_K)
encode dec_conc, gen(d0_judgment)
sum d0_judgment /*count number of votes = 10389  */ /*count number of decisions = 1248 */
drop dec_conc

encode applicant_ombudsman, gen(applicant_ombudsman_c)
drop applicant_ombudsman
gen appl_ombudsman =0 if applicant_ombudsman_c==1
replace appl_ombudsman =1 if applicant_ombudsman_c==2

encode applicant_senators, gen(applicant_senators_c)
drop applicant_senators
gen appl_senators =0 if applicant_senators_c==1
replace appl_senators =1 if applicant_senators_c==2

encode applicant_sejm, gen(applicant_sejm_c)
drop applicant_sejm
gen appl_sejm =0 if applicant_sejm_c==1
replace appl_sejm =1 if applicant_sejm_c==2

encode applicant_president, gen(applicant_president_c)
drop applicant_president
gen appl_president =0 if applicant_president_c==1
replace appl_president =1 if applicant_president_c==2

drop  law issue bench decision_no dissent_reasoning dissent_judgment dissent_procedural dissentcomment impossible_identify_dissenting length type political_affiliation member_proceedings additionalcommentsreprogovt
drop applicant_ombudsman_c applicant_senators_c applicant_sejm_c applicant_president_c
drop political_affiliation_c 
drop judges judgment applicant

gen break =1 if year>=2016
recode break .=0
split date_out, generate(month_out) limit(3)
replace break=1 if month_out2=="december" & month_out3=="2015"
replace break=1 if month_out2=="november" & month_out3=="2015"

gen political_affiliation_PO_break=political_affiliation_PO*break
gen political_affiliation_PIS_break=political_affiliation_PIS*break
gen political_affiliation_SLD_break=political_affiliation_SLD*break

gen political_alignment_PO_break =political_alignment_PO*break
gen political_alignment_PIS_break=political_alignment_PIS*break
gen political_alignment_SLD_break=political_alignment_SLD*break


tab year
gen year_2003=1 if year==2003
recode year_2003 .=0
gen year_2004=1 if year==2004
recode year_2004 .=0
gen year_2005=1 if year==2005
recode year_2004 .=0
gen year_2006=1 if year==2006
recode year_2006 .=0
gen year_2007=1 if year==2007
recode year_2007 .=0
gen year_2008=1 if year==2008
recode year_2008 .=0
gen year_2009=1 if year==2009
recode year_2009 .=0
gen year_2010=1 if year==2010
recode year_2010 .=0
gen year_2011=1 if year==2011
recode year_2011 .=0
gen year_2012=1 if year==2012
recode year_2012 .=0
gen year_2013=1 if year==2013
recode year_2013 .=0
gen year_2014=1 if year==2014
recode year_2014 .=0
gen year_2015=1 if year==2015
recode year_2015 .=0
gen year_2016=1 if year==2016
recode year_2016 .=0
gen year_2017=1 if year==2017
recode year_2017 .=0
gen year_2018=1 if year==2018
recode year_2018 .=0
gen year_2019=1 if year==2019
recode year_2019 .=0
gen year_2020=1 if year==2020
recode year_2020 .=0
gen year_2021=1 if year==2021
recode year_2021 .=0
gen year_2022=1 if year==2022
recode year_2022 .=0

gen political_affiliation_PO_2003=political_affiliation_PO*year_2003
gen political_affiliation_PO_2004=political_affiliation_PO*year_2004
gen political_affiliation_PO_2005=political_affiliation_PO*year_2005
gen political_affiliation_PO_2006=political_affiliation_PO*year_2006
gen political_affiliation_PO_2007=political_affiliation_PO*year_2007
gen political_affiliation_PO_2008=political_affiliation_PO*year_2008
gen political_affiliation_PO_2009=political_affiliation_PO*year_2009
gen political_affiliation_PO_2010=political_affiliation_PO*year_2010
gen political_affiliation_PO_2011=political_affiliation_PO*year_2011
gen political_affiliation_PO_2012=political_affiliation_PO*year_2012
gen political_affiliation_PO_2013=political_affiliation_PO*year_2013
gen political_affiliation_PO_2014=political_affiliation_PO*year_2014
gen political_affiliation_PO_2016=political_affiliation_PO*year_2016
gen political_affiliation_PO_2017=political_affiliation_PO*year_2017
gen political_affiliation_PO_2018=political_affiliation_PO*year_2018
gen political_affiliation_PO_2019=political_affiliation_PO*year_2019
gen political_affiliation_PO_2020=political_affiliation_PO*year_2020
gen political_affiliation_PO_2021=political_affiliation_PO*year_2021
gen political_affiliation_PO_2022=political_affiliation_PO*year_2022

gen political_affiliation_PIS_2003=political_affiliation_PIS*year_2003
gen political_affiliation_PIS_2004=political_affiliation_PIS*year_2004
gen political_affiliation_PIS_2005=political_affiliation_PIS*year_2005
gen political_affiliation_PIS_2006=political_affiliation_PIS*year_2006
gen political_affiliation_PIS_2007=political_affiliation_PIS*year_2007
gen political_affiliation_PIS_2008=political_affiliation_PIS*year_2008
gen political_affiliation_PIS_2009=political_affiliation_PIS*year_2009
gen political_affiliation_PIS_2010=political_affiliation_PIS*year_2010
gen political_affiliation_PIS_2011=political_affiliation_PIS*year_2011
gen political_affiliation_PIS_2012=political_affiliation_PIS*year_2012
gen political_affiliation_PIS_2013=political_affiliation_PIS*year_2013
gen political_affiliation_PIS_2014=political_affiliation_PIS*year_2014
gen political_affiliation_PIS_2016=political_affiliation_PIS*year_2016
gen political_affiliation_PIS_2017=political_affiliation_PIS*year_2017
gen political_affiliation_PIS_2018=political_affiliation_PIS*year_2018
gen political_affiliation_PIS_2019=political_affiliation_PIS*year_2019
gen political_affiliation_PIS_2020=political_affiliation_PIS*year_2020
gen political_affiliation_PIS_2021=political_affiliation_PIS*year_2021
gen political_affiliation_PIS_2022=political_affiliation_PIS*year_2022

gen political_affiliation_SLD_2003=political_affiliation_SLD*year_2003
gen political_affiliation_SLD_2004=political_affiliation_SLD*year_2004
gen political_affiliation_SLD_2005=political_affiliation_SLD*year_2005
gen political_affiliation_SLD_2006=political_affiliation_SLD*year_2006
gen political_affiliation_SLD_2007=political_affiliation_SLD*year_2007
gen political_affiliation_SLD_2008=political_affiliation_SLD*year_2008
gen political_affiliation_SLD_2009=political_affiliation_SLD*year_2009
gen political_affiliation_SLD_2010=political_affiliation_SLD*year_2010
gen political_affiliation_SLD_2011=political_affiliation_SLD*year_2011
gen political_affiliation_SLD_2012=political_affiliation_SLD*year_2012
gen political_affiliation_SLD_2013=political_affiliation_SLD*year_2013
gen political_affiliation_SLD_2014=political_affiliation_SLD*year_2014
gen political_affiliation_SLD_2016=political_affiliation_SLD*year_2016
gen political_affiliation_SLD_2017=political_affiliation_SLD*year_2017
gen political_affiliation_SLD_2018=political_affiliation_SLD*year_2018
gen political_affiliation_SLD_2019=political_affiliation_SLD*year_2019
gen political_affiliation_SLD_2020=political_affiliation_SLD*year_2020
gen political_affiliation_SLD_2021=political_affiliation_SLD*year_2021
gen political_affiliation_SLD_2022=political_affiliation_SLD*year_2022

gen PO_appointed_after2015 =political_affiliation_PO* appointed_after2015
gen PIS_appointed_after2015=political_affiliation_PIS*appointed_after2015
gen SLD_appointed_after2015=political_affiliation_SLD*appointed_after2015
gen PO_appointed_after2015_break =political_affiliation_PO* appointed_after2015*break
gen PIS_appointed_after2015_break=political_affiliation_PIS*appointed_after2015*break
gen SLD_appointed_after2015_break=political_affiliation_SLD*appointed_after2015*break

gen PO_alignment_after2015 =political_alignment_PO*appointed_after2015
gen PIS_alignment_after2015=political_alignment_PIS*appointed_after2015
gen SLD_alignment_after2015=political_alignment_SLD*appointed_after2015
gen PO_alignment_after2015_break =political_alignment_PO* appointed_after2015*break
gen PIS_alignment_after2015_break=political_alignment_PIS*appointed_after2015*break
gen SLD_alignment_after2015_break=political_alignment_SLD*appointed_after2015*break

**************REGRESSIONS *******************

*TAB 1 DEF (affiliation-affiliation, affiliation-appointment, alignment-appointment)

*no covariates - affiliation - all parties affiliation after break 
regress progovt appl_*                               validation           political_affiliation_PO political_affiliation_PIS political_affiliation_SLD  political_affiliation_PO_break political_affiliation_PIS_break political_affiliation_SLD_break break, vce (robust) 
outreg2 using BASELINE_progovt.xls, replace

*no covariates - affiliation - ONLY PIS affiliation after break 
regress progovt appl_*                               validation           political_affiliation_PO political_affiliation_PIS political_affiliation_SLD   political_affiliation_PIS_break break  , vce (robust) 
outreg2 using BASELINE_progovt.xls, append 

*no covariates - affiliation - all parties APPOINTMENT after break 
regress progovt appl_*                               validation           political_affiliation_PO political_affiliation_PIS political_affiliation_SLD    PO_appointed_after2015_break  PIS_appointed_after2015_break SLD_appointed_after2015_break          , vce (robust) 
outreg2 using BASELINE_progovt.xls, append

*no covariates - ALIGNMENT - all parties APPOINTMENT after break 
regress progovt appl_*                               validation           political_alignment_PO political_alignment_PIS political_alignment_SLD  political_alignment_PO_break political_alignment_PIS_break political_alignment_SLD_break , vce (robust) 
outreg2 using BASELINE_progovt.xls, append

*yes covariates - affiliation - all parties affiliation after break 
regress progovt appl_* female prof age length_months validation unanimous political_affiliation_PO political_affiliation_PIS political_affiliation_SLD  political_affiliation_PO_break political_affiliation_PIS_break political_affiliation_SLD_break break, vce (robust) 
outreg2 using BASELINE_progovt.xls, append

*yes covariates - affiliation - ONLY PIS affiliation after break 
regress progovt appl_* female prof age length_months validation unanimous political_affiliation_PO political_affiliation_PIS political_affiliation_SLD   political_affiliation_PIS_break break  , vce (robust) 
outreg2 using BASELINE_progovt.xls, append 

*yes covariates - affiliation - all parties APPOINTMENT after break 
regress progovt appl_* female prof age length_months validation unanimous political_affiliation_PO political_affiliation_PIS political_affiliation_SLD    PO_appointed_after2015_break  PIS_appointed_after2015_break SLD_appointed_after2015_break          , vce (robust) 
outreg2 using BASELINE_progovt.xls, append

*yes covariates - ALIGNMENT - all parties APPOINTMENT after break 
regress progovt appl_* female prof age length_months validation unanimous political_alignment_PO political_alignment_PIS political_alignment_SLD  political_alignment_PO_break political_alignment_PIS_break political_alignment_SLD_break , vce (robust) 
outreg2 using BASELINE_progovt.xls, append


*TAB A3 APPENDIX DEF (affiliation-affiliation, affiliation-appointment, alignment-appointment)

*no covariates - affiliation - all parties affiliation after break 
dlogit2 progovt appl_*                               validation           political_affiliation_PO political_affiliation_PIS political_affiliation_SLD  political_affiliation_PO_break political_affiliation_PIS_break political_affiliation_SLD_break break, vce (robust) 
outreg2 using BASELINE_logit_progovt.xls, replace

*no covariates - affiliation - ONLY PIS affiliation after break 
dlogit2 progovt appl_*                               validation           political_affiliation_PO political_affiliation_PIS political_affiliation_SLD   political_affiliation_PIS_break break  , vce (robust) 
outreg2 using BASELINE_logit_progovt.xls, append 

*no covariates - affiliation - all parties APPOINTMENT after break 
dlogit2 progovt appl_*                               validation           political_affiliation_PO political_affiliation_PIS political_affiliation_SLD    PO_appointed_after2015_break  PIS_appointed_after2015_break SLD_appointed_after2015_break          , vce (robust) 
outreg2 using BASELINE_logit_progovt.xls, append 

*no covariates - ALIGNMENT - all parties APPOINTMENT after break 
dlogit2 progovt appl_*                               validation           political_alignment_PO political_alignment_PIS political_alignment_SLD  political_alignment_PO_break political_alignment_PIS_break political_alignment_SLD_break , vce (robust) 
outreg2 using BASELINE_logit_progovt.xls, append 

*yes covariates - affiliation - all parties affiliation after break 
dlogit2 progovt appl_* female prof age length_months validation unanimous political_affiliation_PO political_affiliation_PIS political_affiliation_SLD  political_affiliation_PO_break political_affiliation_PIS_break political_affiliation_SLD_break break, vce (robust) 
outreg2 using BASELINE_logit_progovt.xls, append 

*yes covariates - affiliation - ONLY PIS affiliation after break 
dlogit2 progovt appl_* female prof age length_months validation unanimous political_affiliation_PO political_affiliation_PIS political_affiliation_SLD   political_affiliation_PIS_break break  , vce (robust) 
outreg2 using BASELINE_logit_progovt.xls, append 

*yes covariates - affiliation - all parties APPOINTMENT after break 
dlogit2 progovt appl_* female prof age length_months validation unanimous political_affiliation_PO political_affiliation_PIS political_affiliation_SLD    PO_appointed_after2015_break  PIS_appointed_after2015_break SLD_appointed_after2015_break          , vce (robust) 
outreg2 using BASELINE_logit_progovt.xls, append 

*yes covariates - ALIGNMENT - all parties APPOINTMENT after break 
dlogit2 progovt appl_* female prof age length_months validation unanimous political_alignment_PO political_alignment_PIS political_alignment_SLD  political_alignment_PO_break political_alignment_PIS_break political_alignment_SLD_break , vce (robust) 
outreg2 using BASELINE_logit_progovt.xls, append 


*TAB 2 DEF * all reg from table 2 for 2013-2018 time span

*no covariates - affiliation - all parties affiliation after break 
regress progovt appl_*                               validation           political_affiliation_PO political_affiliation_PIS political_affiliation_SLD  political_affiliation_PO_break political_affiliation_PIS_break political_affiliation_SLD_break break if year==2008 |year==2009 |year==2010 |year==2011 |year==2012 |year==2013 |year==2014 | year==2015 | year==2016 | year==2017 | year==2018 | year==2019 | year==2020 |year==2021 | year==2022 |year==2023 , vce (robust) 
outreg2 using BALANCED_progovt.xls, replace

*no covariates - affiliation - ONLY PIS affiliation after break 
regress progovt appl_*                               validation           political_affiliation_PO political_affiliation_PIS political_affiliation_SLD   political_affiliation_PIS_break break  if year==2008 |year==2009 |year==2010 |year==2011 |year==2012 |year==2013 |year==2014 | year==2015 | year==2016 | year==2017 | year==2018 | year==2019 | year==2020 |year==2021 | year==2022 |year==2023 , vce (robust) 
outreg2 using BALANCED_progovt.xls, append 

*no covariates - affiliation - all parties APPOINTMENT after break 
regress progovt appl_*                               validation           political_affiliation_PO political_affiliation_PIS political_affiliation_SLD    PO_appointed_after2015_break  PIS_appointed_after2015_break SLD_appointed_after2015_break          if year==2008 |year==2009 |year==2010 |year==2011 |year==2012 |year==2013 |year==2014 | year==2015 | year==2016 | year==2017 | year==2018 | year==2019 | year==2020 |year==2021 | year==2022 |year==2023 , vce (robust) 
outreg2 using BALANCED_progovt.xls, append

*no covariates - ALIGNMENT - all parties APPOINTMENT after break 
regress progovt appl_*                               validation           political_alignment_PO political_alignment_PIS political_alignment_SLD  political_alignment_PO_break political_alignment_PIS_break political_alignment_SLD_break if year==2008 |year==2009 |year==2010 |year==2011 |year==2012 |year==2013 |year==2014 | year==2015 | year==2016 | year==2017 | year==2018 | year==2019 | year==2020 |year==2021 | year==2022 |year==2023 , vce (robust) 
outreg2 using BALANCED_progovt.xls, append

*yes covariates - affiliation - all parties affiliation after break 
regress progovt appl_* female prof age length_months validation unanimous political_affiliation_PO political_affiliation_PIS political_affiliation_SLD  political_affiliation_PO_break political_affiliation_PIS_break political_affiliation_SLD_break break if year==2008 |year==2009 |year==2010 |year==2011 |year==2012 |year==2013 |year==2014 | year==2015 | year==2016 | year==2017 | year==2018 | year==2019 | year==2020 |year==2021 | year==2022 |year==2023 , vce (robust) 
outreg2 using BALANCED_progovt.xls, append

*yes covariates - affiliation - ONLY PIS affiliation after break 
regress progovt appl_* female prof age length_months validation unanimous political_affiliation_PO political_affiliation_PIS political_affiliation_SLD   political_affiliation_PIS_break break  if year==2008 |year==2009 |year==2010 |year==2011 |year==2012 |year==2013 |year==2014 | year==2015 | year==2016 | year==2017 | year==2018 | year==2019 | year==2020 |year==2021 | year==2022 |year==2023 , vce (robust) 
outreg2 using BALANCED_progovt.xls, append 

*yes covariates - affiliation - all parties APPOINTMENT after break 
regress progovt appl_* female prof age length_months validation unanimous political_affiliation_PO political_affiliation_PIS political_affiliation_SLD    PO_appointed_after2015_break  PIS_appointed_after2015_break SLD_appointed_after2015_break          if year==2008 |year==2009 |year==2010 |year==2011 |year==2012 |year==2013 |year==2014 | year==2015 | year==2016 | year==2017 | year==2018 | year==2019 | year==2020 |year==2021 | year==2022 |year==2023 , vce (robust) 
outreg2 using BALANCED_progovt.xls, append

*yes covariates - ALIGNMENT - all parties APPOINTMENT after break 
regress progovt appl_* female prof age length_months validation unanimous political_alignment_PO political_alignment_PIS political_alignment_SLD  political_alignment_PO_break political_alignment_PIS_break political_alignment_SLD_break if year==2008 |year==2009 |year==2010 |year==2011 |year==2012 |year==2013 |year==2014 | year==2015 | year==2016 | year==2017 | year==2018 | year==2019 | year==2020 |year==2021 | year==2022 |year==2023 , vce (robust) 
outreg2 using BALANCED_progovt.xls, append


*TAB 3

gen PO_appointed_after2015_2012=1  if PO_appointed_after2015==1  & year==2012
gen PIS_appointed_after2015_2012=1 if PIS_appointed_after2015==1 & year==2012
gen SLD_appointed_after2015_2012=1 if SLD_appointed_after2015==1 & year==2012

gen PO_appointed_after2015_2013=1  if PO_appointed_after2015==1  & year==2013
gen PIS_appointed_after2015_2013=1 if PIS_appointed_after2015==1 & year==2013
gen SLD_appointed_after2015_2013=1 if SLD_appointed_after2015==1 & year==2013

gen PO_appointed_after2015_2014=1  if PO_appointed_after2015==1  & year==2014
gen PIS_appointed_after2015_2014=1 if PIS_appointed_after2015==1 & year==2014
gen SLD_appointed_after2015_2014=1 if SLD_appointed_after2015==1 & year==2014

gen PO_appointed_after2015_2016=1  if PO_appointed_after2015==1  & year==2016
gen PIS_appointed_after2015_2016=1 if PIS_appointed_after2015==1 & year==2016
gen SLD_appointed_after2015_2016=1 if SLD_appointed_after2015==1 & year==2016

gen PO_appointed_after2015_2017=1  if PO_appointed_after2015==1  & year==2017
gen PIS_appointed_after2015_2017=1 if PIS_appointed_after2015==1 & year==2017
gen SLD_appointed_after2015_2017=1 if SLD_appointed_after2015==1 & year==2017

gen PO_appointed_after2015_2018=1  if PO_appointed_after2015==1  & year==2018
gen PIS_appointed_after2015_2018=1 if PIS_appointed_after2015==1 & year==2018
gen SLD_appointed_after2015_2018=1 if SLD_appointed_after2015==1 & year==2018

gen PO_appointed_after2015_2019=1  if PO_appointed_after2015==1  & year==2019
gen PIS_appointed_after2015_2019=1 if PIS_appointed_after2015==1 & year==2019
gen SLD_appointed_after2015_2019=1 if SLD_appointed_after2015==1 & year==2019

recode PO_appointed_after2015_2012  .=0
recode PIS_appointed_after2015_2012  .=0 
recode SLD_appointed_after2015_2012  .=0 

recode PO_appointed_after2015_2013  .=0
recode PIS_appointed_after2015_2013  .=0 
recode SLD_appointed_after2015_2013  .=0 

recode PO_appointed_after2015_2014   .=0
recode PIS_appointed_after2015_2014  .=0
recode SLD_appointed_after2015_2014  .=0

recode PO_appointed_after2015_2016  .=0 
recode PIS_appointed_after2015_2016  .=0 
recode SLD_appointed_after2015_2016  .=0 

recode PO_appointed_after2015_2017  .=0
recode PIS_appointed_after2015_2017  .=0 
recode SLD_appointed_after2015_2017  .=0

recode PO_appointed_after2015_2018  .=0  
recode PIS_appointed_after2015_2018  .=0
recode SLD_appointed_after2015_2018  .=0

recode PO_appointed_after2015_2019  .=0  
recode PIS_appointed_after2015_2019  .=0
recode SLD_appointed_after2015_2019  .=0

*For identification, we omit the year dummy immediately preceding the treatment (2015)

regress progovt appl_*                               validation           political_affiliation_PO political_affiliation_PIS political_affiliation_SLD political_affiliation_PO_2012 political_affiliation_PIS_2012 political_affiliation_SLD_2012  political_affiliation_PO_2013 political_affiliation_PIS_2013 political_affiliation_SLD_2013 political_affiliation_PO_2014 political_affiliation_PIS_2014 political_affiliation_SLD_2014  political_affiliation_PO_2016 political_affiliation_PIS_2016 political_affiliation_SLD_2016 political_affiliation_PO_2017 political_affiliation_PIS_2017 political_affiliation_SLD_2017 political_affiliation_PO_2018 political_affiliation_PIS_2018 political_affiliation_SLD_2018 political_affiliation_PO_2019 political_affiliation_PIS_2019 political_affiliation_SLD_2019 year_2012 year_2013 year_2014 year_2016 year_2017 year_2018 year_2019  if year==2012 |year==2013 |year==2014 | year==2015 | year==2016 | year==2017 | year==2018 | year==2019
* no political_affiliation_SLD_2017 (omitted)
* political_affiliation_PIS_2017 collinear with year 2017  
outreg2 using DYNAMIC_progovt.xls,     replace 

regress progovt appl_*                               validation           political_affiliation_PO political_affiliation_PIS political_affiliation_SLD PO_appointed_after2015_2012 PIS_appointed_after2015_2012 SLD_appointed_after2015_2012 PO_appointed_after2015_2013 PIS_appointed_after2015_2013 SLD_appointed_after2015_2013 PO_appointed_after2015_2014 PIS_appointed_after2015_2014 SLD_appointed_after2015_2014  PO_appointed_after2015_2016 PIS_appointed_after2015_2016 SLD_appointed_after2015_2016  PO_appointed_after2015_2017 PIS_appointed_after2015_2017 SLD_appointed_after2015_2017  PO_appointed_after2015_2018 PIS_appointed_after2015_2018 SLD_appointed_after2015_2018 PO_appointed_after2015_2019 PIS_appointed_after2015_2019 SLD_appointed_after2015_2019 year_2012 year_2013 year_2014 year_2016 year_2017 year_2018 year_2019  if year==2012 |year==2013 |year==2014 | year==2015 | year==2016 | year==2017 | year==2018 | year==2019
* no political_affiliation_SLD_2017 (omitted)
* political_affiliation_PIS_2017 collinear with year 2017  
outreg2 using DYNAMIC_progovt.xls,     append 

regress progovt appl_*                               validation           political_affiliation_PO political_affiliation_PIS political_affiliation_SLD political_affiliation_PO_2013 political_affiliation_PIS_2013 political_affiliation_SLD_2013 political_affiliation_PO_2014 political_affiliation_PIS_2014 political_affiliation_SLD_2014  political_affiliation_PO_2016 political_affiliation_PIS_2016 political_affiliation_SLD_2016 political_affiliation_PO_2017 political_affiliation_PIS_2017 political_affiliation_SLD_2017 political_affiliation_PO_2018 political_affiliation_PIS_2018 political_affiliation_SLD_2018 year_2013  year_2014 year_2016 year_2017 year_2018   if year==2013 |year==2014 | year==2015 | year==2016 | year==2017 | year==2018
* no political_affiliation_SLD_2017 (omitted)
* political_affiliation_PIS_2017 collinear with year 2017  
outreg2 using DYNAMIC_progovt.xls,     append 

regress progovt appl_*                               validation           political_affiliation_PO political_affiliation_PIS political_affiliation_SLD PO_appointed_after2015_2013 PIS_appointed_after2015_2013 SLD_appointed_after2015_2013 PO_appointed_after2015_2014 PIS_appointed_after2015_2014 SLD_appointed_after2015_2014  PO_appointed_after2015_2016 PIS_appointed_after2015_2016 SLD_appointed_after2015_2016  PO_appointed_after2015_2017 PIS_appointed_after2015_2017 SLD_appointed_after2015_2017  PO_appointed_after2015_2018 PIS_appointed_after2015_2018 SLD_appointed_after2015_2018  year_2013 year_2014 year_2016 year_2017 year_2018   if year==2013 |year==2014 | year==2015 | year==2016 | year==2017 | year==2018
* no political_affiliation_SLD_2017 (omitted)
* political_affiliation_PIS_2017 collinear with year 2017  
outreg2 using DYNAMIC_progovt.xls,     append 

regress progovt appl_*                               validation           political_affiliation_PO political_affiliation_PIS political_affiliation_SLD                                                                                            political_affiliation_PO_2014 political_affiliation_PIS_2014 political_affiliation_SLD_2014  political_affiliation_PO_2016 political_affiliation_PIS_2016 political_affiliation_SLD_2016 political_affiliation_PO_2017 political_affiliation_PIS_2017 political_affiliation_SLD_2017                                                                                                         year_2014 year_2016                       if              year==2014 | year==2015 | year==2016 | year==2017 
* no political_affiliation_SLD_2017 (omitted)
* political_affiliation_PIS_2017 collinear with year 2017  
outreg2 using DYNAMIC_progovt.xls,     append

regress progovt appl_*                               validation           political_affiliation_PO political_affiliation_PIS political_affiliation_SLD                                                                                            PO_appointed_after2015_2014 PIS_appointed_after2015_2014 SLD_appointed_after2015_2014  PO_appointed_after2015_2016 PIS_appointed_after2015_2016 SLD_appointed_after2015_2016 PO_appointed_after2015_2017 PIS_appointed_after2015_2017 SLD_appointed_after2015_2017                                                                                                          year_2014 year_2016                       if              year==2014 | year==2015 | year==2016 | year==2017 
* no political_affiliation_SLD_2017 (omitted)
* political_affiliation_PIS_2017 collinear with year 2017 
outreg2 using DYNAMIC_progovt.xls,     append

regress progovt appl_*                               validation           political_affiliation_PO political_affiliation_PIS political_affiliation_SLD                                                                                                                                                                                                       political_affiliation_PO_2016 political_affiliation_PIS_2016 political_affiliation_SLD_2016                                                                                                                                                               year_2016                                          if              year==2015 | year==2016  
* no political_affiliation_SLD_2017 (omitted)
* political_affiliation_PIS_2017 collinear with year 2017  
outreg2 using DYNAMIC_progovt.xls,     append

regress progovt appl_*                               validation           political_affiliation_PO political_affiliation_PIS political_affiliation_SLD                                                                                                                                                                                                       PO_appointed_after2015_2016 PIS_appointed_after2015_2016 SLD_appointed_after2015_2016                                                                                                                                                               year_2016                                          if              year==2015 | year==2016    
* no political_affiliation_SLD_2017 (omitted)
* political_affiliation_PIS_2017 collinear with year 2017  
outreg2 using DYNAMIC_progovt.xls,     append



*****************
*STOP
*****************

